#include <iostream>
#include "tcp_server.h"
#include <cstdlib>
#include <memory>
#include "daemon.h"
using namespace std;

void usage(string procgress)
{
    cout << "usage error:" << procgress << "port" << endl;
}

string echoservice(const string &message)
{
    return message;
}

int main(int args, char *argv[])
{
    if (args != 2)
    {
        usage(argv[0]);
        exit(USAGE_ERR);
    }

    uint16_t port = atoi(argv[1]);
    unique_ptr<TcpServer> tcp(new TcpServer(echoservice, port));

    tcp->init_service();
    daemon();
    tcp->start_service();

    return 0;
}